package com.example.demo.nios;

import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;

public class Server {
    public static void main(String[] args) throws Exception {
        ServerSocketChannel server = ServerSocketChannel.open();
        server.socket().bind(new InetSocketAddress(10000));
        server.configureBlocking(false);
        ByteBuffer buffer = ByteBuffer.allocate(1024);
        while (true){
            SocketChannel channel = server.accept();
            if(channel != null){
              buffer.clear();
                int read = channel.read(buffer);
                    buffer.flip();
                        System.out.println((char)buffer.get());
            }
        }

    }
}
